<?php
/**
 * Created by PhpStorm.
 * User: iraklis
 * Date: 12/8/13
 * Time: 6:43 PM
 */
session_start();
if (!isset($_SESSION["level"])) header("location:login.php");
include 'config.php';
include 'db_connection.php';

$userID = $_SESSION['u_id'];
$events = array();
$query = mysql_query("SELECT * FROM REMINDERS_RECURRANCY WHERE u_id = \"$userID\"");
if (!$query) {
    die('Invalid SELECT query: ' . mysql_error());
}

while ($row = mysql_fetch_assoc($query)) {
    $eventArray['id'] = $row['event_id'];
    $eventArray['parent_id'] = $row['parent_id'];
    $eventArray['title'] = stripslashes($row['title']);
    $eventArray['start'] = $row['start'];
    $eventArray['end'] = $row['end'];
    $eventArray['url'] = "edit_reminder.php?event_id=" . $row['event_id'];
    $events[] = $eventArray;
}// end of while
$_SESSION['event'] = $events;
echo json_encode($events);
